<?php
require("../class/connect.php");
include("../class/db_sql.php");
include("../class/config.php");
include("../class/class.php");
include("../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
is_login($logininid,$loginin,$loginrnd);
$classid=(int)$_GET['classid'];
$id=(int)$_GET['id'];
$enews=$_GET['enews'];
//验证权限
CheckLevel($logininid,$loginin,$classid,"cj");
if($_GET['from'])
{
	$listclasslink="ListPageInfoClass.php";
}
else
{
	$listclasslink="ListInfoClass.php";
}
//节点名称
$cr=$empire->fetch1("select classname,newsclassid,classid,tbname from {$dbtbpre}enewsinfoclass where classid='$classid'");
if(!$cr[classid])
{
	printerror("ErrorUrl","history.go(-1)");
}
$r=$empire->fetch1("select * from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where id='$id'");
if(empty($r[id]))
{
	printerror("ErrorUrl","history.go(-1)");
}
//模型
$modid=$class_r[$cr[newsclassid]][modid];
$modr=$empire->fetch1("select enter from {$dbtbpre}enewsmod where mid='$modid'");
//会员组
$sql1=$empire->query("select * from {$dbtbpre}enewsmembergroup order by level");
while($l_r=$empire->fetch($sql1))
{
	$ygroup.="<option value=".$l_r[groupid].">".$l_r[groupname]."</option>";
}
//----------------特殊模型----------------
//图片系统模型
if(strstr($modr[enter],"morepic<"))
{
	$morepicpath="";
	$morepicnum=0;
if($r[morepic])
{
    $r[morepic]=stripSlashes($r[morepic]);
    //下载地址
    $j=0;
    $pd_record=explode("\r\n",$r[morepic]);
    for($i=0;$i<count($pd_record);$i++)
    {
		$j=$i+1;
    	$pd_field=explode("::::::",$pd_record[$i]);
		$morepicpath.="<tr> 
    <td width='7%'><div align=center>".$j."</div></td>
    <td width='33%'><div align=center>
        <input name=msmallpic[] type=text value='".$pd_field[0]."' size=28 id=msmallpic".$j." ondblclick=\"SpOpenChFile(1,'msmallpic".$j."');\">
		<br><input type=file name=msmallpfile[] size=15>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mbigpic[] type=text value='".$pd_field[1]."' size=28 id=mbigpic".$j." ondblclick=\"SpOpenChFile(1,'mbigpic".$j."');\">
		<br><input type=file name=mbigpfile[] size=15>
      </div></td>
    <td width='30%'><div align=center>
        <input name=mpicname[] type=text value='".$pd_field[2]."'><input type=hidden name=mpicid[] value=".$j."><input type=checkbox name=mdelpicid[] value=".$j.">删
      </div></td>
  </tr>";
    }
    $morepicnum=$j;
    $morepicpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$morepicpath."</table>";
}
}
//下载地址前缀
if(strstr($modr[enter],"downpath<")||strstr($modr[enter],"onlinepath<"))
{
	$downurlqz="";
	$newdownqz="";
	$downsql=$empire->query("select urlname,url,urlid from {$dbtbpre}enewsdownurlqz order by urlid");
	while($downr=$empire->fetch($downsql))
	{
		$downurlqz.="<option value='".$downr[url]."'>".$downr[urlname]."</option>";
		$newdownqz.="<option value='".$downr[urlid]."'>".$downr[urlname]."</option>";
	}
}
//下载系统模型
if(strstr($modr[enter],"downpath<"))
{
$downloadpath="";
$editnum=0;
if($r[downpath])
{
	$r[downpath]=stripSlashes($r[downpath]);
	//下载地址
	$j=0;
	$d_record=explode("\r\n",$r[downpath]);
	for($i=0;$i<count($d_record);$i++)
	{
		$j=$i+1;
		$d_field=explode("::::::",$d_record[$i]);
		//权限
		$tgroup=str_replace(" value=".$d_field[2].">"," value=".$d_field[2]." selected>",$ygroup);
		//地址前缀
		$tnewdownqz=str_replace(" value='".$d_field[4]."'>"," value='".$d_field[4]."' selected>",$newdownqz);
		$downloadpath.="<tr><td width='7%'><div align=center>".$j."</div></td><td width='19%'><div align=left><input name=downname[] type=text id=downname[] value='".$d_field[0]."' size=17></div></td><td width='40%'><input name=downpath[] type=text id=downpath".$j." value='".$d_field[1]."' size=36 ondblclick=\"SpOpenChFile(0,'downpath".$j."');\"><select name=thedownqz[]><option value=''>--地址前缀--</option>".$tnewdownqz."</select><input type=hidden name=pathid[] value=".$j."><input type=checkbox name=delpathid[] value=".$j.">删</td><td width='21%'><div align=center><select name=downuser[] id=select><option value=0>游客</option>".$tgroup."</select></div></td><td width='13%'><div align=center><input name=fen[] type=text id=fen[] value='".$d_field[3]."' size=6></div></td></tr>";
	}
	$editnum=$j;
	$downloadpath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$downloadpath."</table>";
}
}
//在线电影模型
if(strstr($modr[enter],"onlinepath<"))
{
$onlinemoviepath="";
$oeditnum=0;
if($r[onlinepath])
{
	$j=0;
	$od_record=explode("\r\n",$r[onlinepath]);
	for($i=0;$i<count($od_record);$i++)
	{
		$j=$i+1;
		$od_field=explode("::::::",$od_record[$i]);
		//权限
		$tgroup=str_replace(" value=".$od_field[2].">"," value=".$od_field[2]." selected>",$ygroup);
		//地址前缀
		$tnewdownqz=str_replace(" value='".$od_field[4]."'>"," value='".$od_field[4]."' selected>",$newdownqz);

		$onlinemoviepath.="<tr><td width='7%'><div align=center>".$j."</div></td><td width='19%'><div align=left><input name=odownname[] type=text value='".$od_field[0]."' size=17></div></td><td width='40%'><input name=odownpath[] type=text value='".$od_field[1]."' size=36 id=odownpath".$j." ondblclick=\"SpOpenChFile(0,'odownpath".$j."');\"><select name=othedownqz[]><option value=''>--地址前缀--</option>".$tnewdownqz."</select><input type=hidden name=opathid[] value=".$j."><input type=checkbox name=odelpathid[] value=".$j.">删</td><td width='21%'><div align=center><select name=odownuser[] id=select><option value=0>游客</option>".$tgroup."</select></div></td><td width='13%'><div align=center><input name=ofen[] type=text value='".$od_field[3]."' size=6></div></td></tr>";
	}
	$oeditnum=$j;
	$onlinemoviepath="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$onlinemoviepath."</table>";
}
}
//播放器
if(strstr($modr[enter],"playerid<"))
{
	$player_sql=$empire->query("select id,player from {$dbtbpre}enewsplayer");
	while($player_r=$empire->fetch($player_sql))
	{
		$select_player='';
		if($r[playerid]==$player_r[id])
		{
			$select_player=' selected';
		}
		$player_class.="<option value='".$player_r[id]."'".$select_player.">".$player_r[player]."</option>";
	}
}
//新闻系统模型
if(strstr($modr[enter],"newstext<"))
{
	$newstext=htmlspecialchars($r[newstext]);
	$htmlareacode="<script type=\"text/javascript\">
      _editor_url = \"editor\";
      _editor_lang = \"en\";
    </script>

<script type=\"text/javascript\" src=\"editor/htmlarea.php?userid=$logininid&username=$loginin&rnd=$loginrnd&classid=$classid\"></script>
<script type=\"text/javascript\" src=\"editor/plugins/FullPage/full-page.js\"></script>
<script type=\"text/javascript\" src=\"editor/plugins/FullPage/lang/en.js\"></script>

<script type=\"text/javascript\">
//HTMLArea.loadPlugin(\"FullPage\");

var editor = null;
function initEditor() {
editor = new HTMLArea(\"newstext\");
editor.registerPlugin(FullPage);

editor.generate();
return false;
}

function DoFile(html) {
	editor.focusEditor();
	editor.insertHTML(html);
}
    </script>";

	$onload=" onload=\"initEditor()\"";
}
$r[smalltext]=htmlspecialchars($r[smalltext]);
//栏目名称
$newsclassid=$cr[newsclassid];
$newsclassname=$class_r[$newsclassid][classname];
$newsbclassname=$class_r[$class_r[$newsclassid][bclassid]][classname];
$newsclass="<font color=red>".$newsbclassname."&nbsp;>&nbsp;".$newsclassname."</font>";
//表单文件
$cjfile="../data/html/editcj".$class_r[$newsclassid][modid].".php";
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改采集信息</title>
<link href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<?=$htmlareacode?>
<script>
function doSpChangeFile(name,url,filesize,filetype,idvar){
	document.getElementById(idvar).value=url;
	if(document.add.filetype!=null)
	{
		if(document.add.filetype.value=='')
		{
			document.add.filetype.value=filetype;
		}
	}
	if(document.add.filesize!=null)
	{
		if(document.add.filesize.value=='')
		{
			document.add.filesize.value=filesize;
		}
	}
}

function SpOpenChFile(type,field){
	window.open('editor/file.php?userid=<?=$logininid?>&username=<?=$loginin?>&rnd=<?=$loginrnd?>&classid=<?=$classid?>&filepass=<?=$filepass?>&type='+type+'&tranfrom=2&field='+field,'','width=700,height=550,scrollbars=yes');
}

function bs(){
	var f=document.add;
	if(f.title.value.length==0){alert("标题还没写");f.title.focus();return false;}
}
function foreColor(){
  if(!Error())	return;
  var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null) document.add.titlecolor.value=arr;
  else document.add.titlecolor.focus();
}
function FieldChangeColor(obj){
  if(!Error())	return;
  var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null) obj.value=arr;
  else obj.focus();
}
</script>
<script src="editor/setday.js"></script>
</head>

<body<?=$onload?>>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr> 
    <td>位置：采集 -&gt; <a href="<?=$listclasslink?>">管理节点</a> &gt; <a href="CheckCj.php?classid=<?=$classid?>&from=<?=$_GET['from']?>">审核采集</a> 
      &gt; 节点名称： 
      <?=$cr[classname]?>
      &gt; 修改采集信息</td>
  </tr>
  <tr>
    <td>入库栏目： 
      <?=$newsclass?>
    </td>
  </tr>
</table>
<form name="add" method="post" enctype="multipart/form-data" action=enews.php>
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr class="header"> 
      <td width="17%" height="25">修改采集信息</td>
      <td width="83%" height="25"><input type=hidden name=from value='<?=$_GET['from']?>'>
	  <input name="id" type="hidden" value="<?=$id?>"> 
        <input name="classid" type="hidden" value="<?=$classid?>">
		<input name="editnum" type="hidden" value="<?=$editnum?>">
        <input name="enews" type="hidden" value="<?=$enews?>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">采集地址：</td>
      <td height="25"><a href="<?=$r[oldurl]?>" target="_blank">
        <?=$r[oldurl]?>
        </a></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">采集时间：</td>
      <td height="25">
        <?=$r[tmptime]?>
      </td>
    </tr>
    <?php
	@include($cjfile);
	?>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">&nbsp;</td>
      <td height="25"><input type="submit" name="Submit" value="修改"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php
db_close();
$empire=null;
?>